package 笔试.隽思信息;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;

public class 分糖果 {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] nums = new int[N];
        for (int i = 0; i < N; i++) {
            nums[i] = sc.nextInt();
        }
        int L = sc.nextInt();
        int R = sc.nextInt();
        System.out.println(solve(N, nums, L, R));
    }

    private static int solve(int n, int[] nums, int l, int r) {
        int more = 0;
        int less = 0;
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < nums.length; i++) {
            int cur = nums[i];
            if (cur < l) {
                less += l - cur;
            } else if (cur > r) {
                more += cur - r;
            } else {
                list.add(cur);
            }
        }

        int ans = 0;
        while (more > 0 && less > 0) {
            more--;
            less--;
            ans++;
        }
        if (more > 0) {
            list.sort(Comparator.naturalOrder());
            for (int i = 0; i < list.size(); i++) {
                Integer num = list.get(i);
                while (num < r) {
                    more--;
                    ans++;
                    num++;
                    if (more == 0) {
                        break;
                    }
                }
            }
        }
        if (less > 0) {
            list.sort(Comparator.reverseOrder());
            for (int i = 0; i < list.size(); i++) {
                Integer num = list.get(i);
                while (num > l) {
                    less--;
                    ans++;
                    if (less == 0) {
                        break;
                    }
                    num--;
                }
            }
        }
        return more == 0 && less == 0 ? ans : -1;
    }

}
